#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
size_t Min=-1;
void dfs(vector<int>& v,int step,int sum)
{
	if (step == v.size() || step == v.size() - 1)
	{
		//cout << sum << " "<<Min;
		if (sum < Min&&sum!=0) Min = sum;
		return;
	}
	sum += v[step];
	if (sum > Min) return;
	dfs(v, step + 2, sum);
	dfs(v, step + 1, sum);
}
int main()
{
	int n;
	while (cin >> n)
	{
		vector<int> v(n + 1);
		for (int i = 0; i < v.size() - 1; i++)
		{
			cin >> v[i];
		}
		v[v.size() - 1] = -1;
		//int sum = 0;
		dfs(v, 0, 0);
		dfs(v, 1, 0);
		cout<<Min;
		Min = -1;
	}
	return 0;
}